package org.baicaix.worms.display.camera {
	
	import flash.display.Sprite;
	import flash.events.Event;
	import flash.events.MouseEvent;
	import flash.filters.BlurFilter;

	/**
	 * 测试显示类
	 * @author baicaix
	 * 2010-9-9
	 */
	public class Target extends Sprite {

		public function Target() {
			init();
		}

		private function init() : void {
			addEventListener(Event.ADDED_TO_STAGE, addToStageHandler);
			addEventListener(MouseEvent.ROLL_OVER, overHandler);
			addEventListener(MouseEvent.ROLL_OUT, outHandler);
			addEventListener(MouseEvent.CLICK, clickHandler);
		}

		private function addToStageHandler(event : Event) : void {
			removeEventListener(Event.ADDED_TO_STAGE, addToStageHandler);
			
			this.graphics.beginFill(Math.random() * 0xFFFFFF);
			this.graphics.drawCircle(0, 0, 100 * Math.random());
			this.graphics.endFill();
			
			this.x = stage.stageWidth * Math.random();
			this.y = stage.stageHeight * Math.random();
		}

		private function overHandler(event : MouseEvent) : void {
			this.filters = [new BlurFilter(26, 12)];
		}

		private function outHandler(event : MouseEvent) : void {
			this.filters = [];
		}

		private function clickHandler(event : MouseEvent) : void {
			Camera.pos(this.x, this.y);
		}
	}
}
